package aavn.ken

class StudentController {
	def index(){
		redirect(action: "list", controller: "student")
	}
	def create(){
		
	}
	def saves(){
		def student = new Student()
		student.properties =  params
		student.save()
		redirect(action: "list", controller: "student")		
	}
	
	def list(){
		[listStudent: Student.list()]
	}
	
	def showDetail(){
		def mssv= request.getParameter("mssv")
		def student = Student.findByMssv(mssv)
		[studentInstance:student]
	}
	def edit(){
		def mssv= request.getParameter("mssv")
		def student = Student.findByMssv(mssv)
		[studentInstance:student]
	}
	def saveUpdate(){
		def mssv=params.mssv
		def student = Student.findByMssv(mssv)
		student.properties = params		
		redirect(action: "list", controller: "student")
	}
	
	def delete(){
		Student student = Student.findByMssv(params.mssv)
		student.delete()
		redirect(action: "list", controller: "student")
	}
	
}
